﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SARUserControls
{
    /// <summary>
    /// Interaction logic for NextStepButton.xaml
    /// </summary>
    public partial class NextStepButton : UserControl
    {
        public NextStepButton()
        {
            InitializeComponent();
        }

        private string windowsTxt;

        //属性WindowsTxt，显示字符串
        public string SARWindowsTxt
        {
            get
            {
                windowsTxt = this.ButtonTxt.Text;
                return windowsTxt;
            }
            set
            {
                windowsTxt = value;
                this.ButtonTxt.Text = windowsTxt;
            }
        }

        //定义鼠标事件
        public event MouseButtonEventHandler SARNextClick;

        private void nextStepBtn_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!isEnabled)
            {
                return;
            }

            this.ButtonTxt.Margin = new Thickness(10.59, 9.29, 0, 0);
            this.gridText.Margin = new Thickness(65.05, 8.29, 0, 0);

            if (SARNextClick != null)
            {
                SARNextClick.Invoke(this, e);
            }
        }

        private bool isEnabled = true;
        public bool SARIsEnabled
        {
            set
            {
                isEnabled = value;
                if (isEnabled)
                {
                    this.Opacity = 1;
                }
                else
                {
                    this.Opacity = 0.5;
                }
            }
            get
            {
                return isEnabled;
            }
        }        

        private void nextStepBtn_MouseLeave(object sender, MouseEventArgs e)
        {
            if (!isEnabled)
            {
                return;
            }
            this.ButtonTxt.Margin = new Thickness(9.59, 8.29, 0, 0);
            this.gridText.Margin = new Thickness(64.05, 7.29, 0, 0);
    
        }

        private void nextStepBtn_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!isEnabled)
            {
                return;
            }
            this.ButtonTxt.Margin = new Thickness(9.59, 8.29, 0, 0);
            this.gridText.Margin = new Thickness(64.05, 7.29, 0, 0);
    
        }
    }
}
